package com.whnk.web.controller.rtms;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.whnk.common.annotation.Log;
import com.whnk.common.enums.BusinessType;
import com.whnk.rtms.domain.PrjInf;
import com.whnk.rtms.service.IPrjInfService;
import com.whnk.framework.web.base.BaseController;
import com.whnk.framework.web.page.TableDataInfo;
import com.whnk.common.base.AjaxResult;

/**
 * 项目 信息操作处理
 * 
 * @author whwhnk
 * @date 2019-04-17
 */
@Controller
@RequestMapping("/rtms/prjInf")
public class PrjInfController extends BaseController
{
    private String prefix = "rtms/prjInf";
	 
	@Autowired
	private IPrjInfService prjInfService;
	
	@RequiresPermissions("rtms:prjInf:view")
	@GetMapping()
	public String prjInf()
	{
	    return prefix + "/prjInf";
	}
	
	/**
	 * 查询项目列表
	 */
	@RequiresPermissions("rtms:prjInf:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(PrjInf prjInf)
	{
		startPage();
        List<PrjInf> list = prjInfService.selectPrjInfList(prjInf);
		return getDataTable(list);
	}
	
	/**
	 * 新增项目
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存项目
	 */
	@RequiresPermissions("rtms:prjInf:add")
	@Log(title = "项目", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(PrjInf prjInf)
	{		
		return toAjax(prjInfService.insertPrjInf(prjInf));
	}

	/**
	 * 修改项目
	 */
	@GetMapping("/edit/{prjId}")
	public String edit(@PathVariable("prjId") String prjId, ModelMap mmap)
	{
		PrjInf prjInf = prjInfService.selectPrjInfById(prjId);
		mmap.put("prjInf", prjInf);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存项目
	 */
	@RequiresPermissions("rtms:prjInf:edit")
	@Log(title = "项目", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(PrjInf prjInf)
	{		
		return toAjax(prjInfService.updatePrjInf(prjInf));
	}
	
	/**
	 * 删除项目
	 */
	@RequiresPermissions("rtms:prjInf:remove")
	@Log(title = "项目", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(prjInfService.deletePrjInfByIds(ids));
	}
	
}
